<template>
  <div>
    <ul>
      <li v-for="(item, key) in arr" :key="key">
        {{ item }} <button @click="del(item)">删除</button>
      </li>
      <button @click="fn">生成</button>
    </ul>
  </div>
</template>

<script>
export default {
  data() {
    return {
      arr: [],
    };
  },
  methods: {
    fn() {
      const a = parseInt(Math.random() * (999 + 1), 10);
      this.arr.push(a);
    },
    del(k) {
      this.arr = this.arr.filter((item) => item !== k);
      // this.arr.splice(k,1)
    },
  },
};
</script>

<style scoped></style>
